package com.example.ycdyus.dailyfruit.utils;

import com.loopj.android.http.AsyncHttpClient;

/**
 * 项目名称：Sybl
 * 类描述：
 * 创建人：zhangwei
 * 创建时间：2015-10-16 下午4:47
 * 修改人：zhangwei
 * 修改时间：2015-10-16 下午4:47
 * 修改备注：
 * @version 1.0
 */

public class AppAsyncTaskHelper {
    private static AppAsyncTaskHelper helper;
    private AsyncHttpClient httpClient;

    private AppAsyncTaskHelper() {
        httpClient = new AsyncHttpClient();
    }

    public static AppAsyncTaskHelper getInstance() {
        if (helper == null) {
            helper = new AppAsyncTaskHelper();
        }
        return helper;
    }

    /**
     * @param url
     * @param params
     * @param list
     * @param ptrListView
     * @param adapter
     * @param page
     * @param type
     */
//    public <T> void post(String url, RequestParams params, final List<T> list, final PullToRefreshListView ptrListView, final BaseAdapter adapter, final int page, final TypeReference<GiftBean<T>> type) {
//        httpClient.post(url, params, new TextHttpResponseHandler() {
//            @Override
//            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
//
//            }
//
//            @Override
//            public void onSuccess(int statusCode, Header[] headers, String responseString) {
//                ptrListView.onRefreshComplete();
//                //解析数据
//                GiftBean bean = (GiftBean)JSONObject.parseObject(responseString, type);
//                if (bean != null) {
//                    if (page == 1 && !list.isEmpty()) {
//                        list.clear();
//                    }
//                    list.addAll(bean.getInfo());
//                    adapter.notifyDataSetChanged();
//                }
//            }
//        });
//    }
}
